﻿using System;
using ASPNETVN.PORTAL.Components.UI;
using System.Collections;
using ASPNETVN.PORTAL.Components.Configuration;

namespace ASPNETVN.PORTAL.Modules.DOCUMENT.HOME.Controls
{
    public partial class Style2 : ModulePage
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (IsPostBack == false)
            {
                Hashtable settings = this.Settings;
                int recordNumber = Convert.ToInt32(settings["RecordNumber"].ToString());
                Guid moduleID = new Guid(settings["DOCUMENT.ModuleID"].ToString());
                gvItem1.DataSource = Components.Item.GetTopItems(moduleID, "PublishedDate", recordNumber, 1).Tables[0].DefaultView;
                gvItem1.DataBind();

                gvItem2.DataSource = Components.Item.GetTopItems(moduleID, "", recordNumber, 1).Tables[0].DefaultView;
                gvItem2.DataBind();
            }
        }

        protected string GetUrl(int itemID)
        {
            Guid tabID = Guid.Empty;
            PortalDataSet ds = PortalConfiguration.GetPortalDataSet();
            Hashtable settings = this.Settings;
            Guid moduleID = new Guid(settings["DOCUMENT.ModuleID"].ToString());

            foreach (PortalDataSet.TabRow tab in ds.Tab.Rows)
            {
                foreach (PortalDataSet.ModuleRow module in tab.GetModuleRows())
                {
                    if (module.ID == new Guid(this.Settings["DOCUMENT.ModuleID"].ToString()))
                    {
                        return string.Format("~/Default.aspx?tabid={0}&mid={1}&itemid={2}&page=detail", tab.ID, moduleID, itemID);
                    }
                }
            }
            return string.Format("~/Default.aspx");
        }
    }
}